package com.ltmall.api.comm;

import java.io.File;

public class PathUtil {
    //活动图片的路径
    public static String getPicPaths(String picName, String dir) {
        String returnName = "";

        if (picName == null || picName.equals("")) {
            return returnName;
        } else if (picName.contains("http")) {
            return picName;
        }

        String prefix = Path.nginxServerBusinessDir + dir + File.separator;
        String[] picArr = picName.split(";");

        //表示只有一张图片
        if (picArr.length == 0) {
            //除去分号
            return (prefix + picName).replace(";", "");
        }

        //存在多张图片
        for (String name : picArr) {
            returnName += (prefix + name + ";");
        }
        return returnName;
    }

    public static String getPicPath(String picPaths, String dir) {
        String returnName = "";

        if (picPaths == null || picPaths.equals("")) {
            return returnName;
        }

        String prefix = Path.nginxServerBusinessDir + dir + File.separator;
        String[] picArr = picPaths.split(";");

        //表示只有一张图片
        if (picArr.length == 0) {
            //除去分号
            return (prefix + picPaths).replace(";", "");
        } else {
            if (!picPaths.contains("http")) {
                return prefix + picArr[0];
            } else {
                return picArr[0];
            }
        }

    }
}
